﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq.Expressions;

namespace SqlSugarAndEntity
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                List<string> WxxList = new List<string>()
                {
                    {"authors" },
                    {"catalog_fzcourse" },
                    {"catalog_topics" },
                    {"course_r_catalog" },
                    {"courses" },
                    {"video_r_author" },
                    {"video_r_course" },
                    {"videos" }
                };
                SqlSugarClient db = new SqlSugarClient(DataBaseConfig._config);
                var TotalPath = Directory.GetCurrentDirectory();
                string[] PathArr = TotalPath.Replace("\\", "/").Split(new string[] { "/bin/" }, StringSplitOptions.None);
                db.DbFirst.Where(t=>WxxList.Contains(t))
                    .SettingClassTemplate(old =>
                    {
                        return old;
                    })
                    .SettingNamespaceTemplate(old =>
                    {
                        return old;
                    })//命名空间 
                    .SettingPropertyTemplate(old =>
                    {
                        return old;
                    })//属性
                    .SettingConstructorTemplate(old =>
                    {
                        return old;
                    })//构造函数
                    .IsCreateAttribute()
                    .CreateClassFile($"{PathArr[0]}/Entity/wxx", "SqlSugarAndEntity.wxx");

                //db.DbFirst.Where(t => !t.Contains('.') && (t == "menuinfo" || t == "dictionary" || t == "orginfo"))
                //    .SettingClassTemplate(old =>
                //    {
                //        return ChildrenTemp;
                //    }).CreateClassFile($"{PathArr[0]}/Entity", "SqlSugarAndEntity");
                Console.WriteLine("生成成功!");
            }
            catch(Exception e)
            {
                Console.WriteLine($"{e.Message}");
            }
            
            Console.ReadKey();
        }
    }
}
